package com.woniuxy02;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author 作者
 * @create 2025-09-08 14:24
 */
public class Test01 {
    public static void main(String[] args) {
//        int[] a={1,52,3,4,5};
//        Arrays.sort(a);
//        System.out.println(Arrays.toString(a));
//        String[] strs={"ccc","aaa","bbb","abc"};
//        Arrays.sort(strs);
//        System.out.println(Arrays.toString(strs));
        Student[] students=new Student[3];
        students[0]=new Student(1,"zs",15);
        students[1]=new Student(2,"ls",17);
        students[2]=new Student(3,"ww",12);
        System.out.println("初始顺序");
        System.out.println(Arrays.toString(students));
//        Arrays.sort(students);
        mysort(students);
        System.out.println(Arrays.toString(students));

    }


    public static void mysort(Object[] a){
        for(int i=0;i<a.length-1;i++){
            for(int j=0;j<a.length-1-i;j++){
               if(((Comparable)a[j]).compareTo(a[j+1])>0){
                    Object temp=a[j];
                    a[j]=a[j+1];
                    a[j+1]=temp;
                }
            }
        }
    }
}

